package router

import (
	"github.com/gin-gonic/gin"
)

type RouteGroup struct {
	Prefix  string
	Route   []Route
	Comment string
	Module  string
}

type Route struct {
	Method      string
	Path        string
	HandlerFunc gin.HandlerFunc
	Comment     string
}

func NewRoute(method, path string, handler gin.HandlerFunc, comment string) Route {
	return Route{
		Method:      method,
		Path:        path,
		HandlerFunc: handler,
		Comment:     comment,
	}
}

func AddRouteGroups(engine *gin.Engine, prefix string, routes []RouteGroup) {
	api := engine.Group(prefix)
	for _, route := range routes {
		group := api.Group(route.Prefix)
		for _, r := range route.Route {
			group.Handle(r.Method, r.Path, r.HandlerFunc)
			continue
		}
	}
}
